import './App.css';
import { Component } from 'react';
import Search from './components/Search';
import Content from './components/Content';
import axios from 'axios';
import { NavLink, Route, Routes } from 'react-router-dom';
import MyRoute from './components/myroute';
export default class App extends Component {
  state = {
    users: [],
  };
  render() {
    const { users } = this.state;
    const name = 'zjl';
    return (
      <div className='App'>
        <NavLink to={{ pathname: '/demo', state: { test: 'asdas', tetet: 'aqq' } }} children='testDemo'></NavLink>
        <Search saveUser={this.saveUser} />
        <Content users={users} />
        <div>
          <Route path='/demo' component={MyRoute} />
        </div>
      </div>
    );
  }
  saveUser = async val => {
    const {
      data: { items: users },
    } = await axios.get(`https://api.github.com/search/users?q=${val}`);
    console.log(users);
    this.setState({ users });
  };
}
